const { resolve } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')


module.exports = {
  entry: './src/js/index.js',
  output: {
    filename: 'js/built.[contenthash:10].js',
    path: resolve(__dirname, 'build')
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './src/index.html',
      minify: {
        collapseWhitespace: true,
        removeComments: true
      }
    }),
  ],
  mode: 'production',
  // 忽略要打包的node_modules
  externals: {
    // 忽略的库名：npm包名
    // 拒绝jQuery包被打包进来，但是要在html中手动引入cdn链接（bootcdn.cn）
    jquery: 'jQuery'
  }
}
